﻿@inject IStringLocalizer<BootstrapBlazor.Shared.Samples.RibbonTabs> Localizer

<RibbonTab Items="@Items" OnMenuClickAsync="@OnMenuClickAsync">
    <div class="@FileClassString">@Localizer["RibbonTabsItemsText1"]</div>
    <div class="@EditClassString">@Localizer["RibbonTabsItemsText2"]</div>
</RibbonTab>

@code {
    [NotNull]
    private IEnumerable<RibbonTabItem>? Items { get; set; }

    private string? FileClassString => CssBuilder.Default("collapse")
    .AddClass("show", ActiveTabText == Localizer["RibbonTabsItemsText1"])
    .Build();

    private string? EditClassString => CssBuilder.Default("collapse")
        .AddClass("show", ActiveTabText == Localizer["RibbonTabsItemsText2"])
        .Build();

    private Task OnMenuClickAsync(RibbonTabItem item)
    {
        ActiveTabText = item.Text;
        StateHasChanged();
        return Task.CompletedTask;
    }

    private string? ActiveTabText { get; set; }

    /// <summary>
    /// OnInitialized method
    /// </summary>
    protected override void OnInitialized()
    {
        Items = new List<RibbonTabItem>()
        {
            new()
            {
                Text = Localizer["RibbonTabsItemsText1"],
                Items = new List<RibbonTabItem>()
                {
                    new() { Text = Localizer["RibbonTabsItems1"], Icon = "fa-solid fa-font-awesome", GroupName = Localizer["ItemsGroupName1"] },
                    new() { Text = Localizer["RibbonTabsItems2"], Icon = "fa-solid fa-font-awesome", GroupName = Localizer["ItemsGroupName1"] },
                    new() { Text = Localizer["RibbonTabsItems3"], Icon = "fa-solid fa-font-awesome", GroupName = Localizer["ItemsGroupName1"] },
                    new() { Text = Localizer["RibbonTabsItems4"], Icon = "fa-solid fa-font-awesome", GroupName = Localizer["ItemsGroupName1"] },
                    new() { Text = Localizer["RibbonTabsItems5"], Icon = "fa-solid fa-font-awesome", GroupName = Localizer["ItemsGroupName1"] },
                    new() { Text = Localizer["RibbonTabsItems6"], Icon = "fa-solid fa-font-awesome", GroupName = Localizer["ItemsGroupName1"] }
                }
            },
            new()
            {
                Text = Localizer["RibbonTabsItemsText2"],
                Items = new List<RibbonTabItem>()
                {
                    new() { Text = Localizer["RibbonTabsItems7"], Icon = "fa-solid fa-font-awesome", GroupName = Localizer["ItemsGroupName2"] },
                    new() { Text = Localizer["RibbonTabsItems8"], Icon = "fa-solid fa-font-awesome", GroupName = Localizer["ItemsGroupName2"] },
                    new() { Text = Localizer["RibbonTabsItems9"], Icon = "fa-solid fa-font-awesome", GroupName = Localizer["ItemsGroupName2"] },
                    new() { Text = Localizer["RibbonTabsItems10"], Icon = "fa-solid fa-font-awesome", GroupName = Localizer["ItemsGroupName2"] },
                    new() { Text = Localizer["RibbonTabsItems11"], Icon = "fa-solid fa-font-awesome", GroupName = Localizer["ItemsGroupName2"] },
                    new() { Text = Localizer["RibbonTabsItems12"], Icon = "fa-solid fa-font-awesome", GroupName = Localizer["ItemsGroupName2"] }
                }
            }
        };

        ActiveTabText = Localizer["RibbonTabsItemsText1"];
    }
}
